package com.admin.dbdao;

import com.admin.bean.Banner;
import com.data.dbdao.BaseDao;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * banner管理的数据层
 *
 * @author:HingLo
 * @create 2017-09-26 14:31
 **/
@Repository
@Transactional
public class BannerAdminDao extends BaseDao {

    public List<?> findAllBannerTypeDao() {
        String hql = "select b.id,b.rid,b.ctime,b.endtime,b.typeid from Banner as b";
        return super.findMassageDao(hql);
    }

    /**
     * 添加banner
     *
     * @param banner
     * @return
     */
    public boolean submitBannerAddAdminDao(Banner banner) {
        return saveMassageDao(banner);
    }

    /**
     * 根据id,删除id
     *
     * @param id
     * @return
     */
    public boolean delBannerAdminDao(String id) {
        String hql = "delete Banner where id=?";
        return updateManyMssageDao(hql, id) > 0;
    }

    /**
     * 根据id,查看banner图
     *
     * @param id
     * @return
     */
    public List<Banner> lookBannerIconDao(String id) {
        String hql = "from Banner where id=?";
        return (List<Banner>) super.findMassageDao(hql, id);
    }


}
